<?php
namespace App\Common;
use PhalApi\Filter;
use PhalApi\Exception\BadRequestException;
class AuthFilter implements Filter
{
    public function check()
    {
//        $user->checkLogin() //检测登录，自主实现
        $di = \PhalApi\DI();
        $api= \PhalApi\DI()->request->get('service','Default.Index'); //获取当前访问的接口
        $userId= \PhalApi\DI()->request->get('user_id',0);//获取用户id参数


        $r= \PhalApi\DI()->authLite->check($api,$userId);
        if(!$r){
            //抛出异常
            throw new BadRequestException('no auth', 1);
        }
    }
}